﻿package javase.socket.server;

import java.io.IOException;
import java.net.*;
import java.io.*;

public class TCPServer {
	public static void main(String[] args) {
		new ServerAccepter(5555);
	}
}

class ServerAccepter implements Runnable {
	ServerSocket ss;
	ServerAccepter(int port) {
		try {
			ss=new ServerSocket(port);
		} catch (IOException e) {
			e.printStackTrace();
		}
		new Thread(this).start();
	}

	@Override
	public void run() {
		int i =0 ;
		while (true) {
			try {
				Socket s = ss.accept();
				BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
				i++;
				String str=br.readLine();
				System.out.println("count:"+i);
				System.out.println("str:"+str);
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

	}

}